/*-----------------------------------------------------------------------------
	6502 Macroassembler and Simulator
		additions
Copyright (C) 2023 Mark Spankus

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-----------------------------------------------------------------------------*/

#ifndef _ohio_scientific_files_
#define _ohio_scientific_files_

class COutputMem;
class CMarkArea;

class COSIFiles
{
  UINT ReadHex8(const TCHAR *&ptr, WORD &sum);
  UINT row;

public:
  void Save65VFormat(CArchive &archive, COutputMem &mem, CMarkArea &area, int prog_start= -1);
  void Load65VFormat(CArchive &archive, COutputMem &mem, CMarkArea &area, int &prog_start);

  void Save65AFormat(CArchive &archive, COutputMem &mem, CMarkArea &area, int prog_start= -1);
  void Load65AFormat(CArchive &archive, COutputMem &mem, CMarkArea &area, int &prog_start);
  
  void SaveMOSChkFormat(CArchive &archive, COutputMem &mem, CMarkArea &area, int prog_start= -1);
  void LoadMOSChkFormat(CArchive &archive, COutputMem &mem, CMarkArea &area, int &prog_start);

  void SaveQSaveFormat(CArchive &archive, COutputMem &mem, CMarkArea &area, int prog_start= -1);
  void LoadQSaveFormat(CArchive &archive, COutputMem &mem, CMarkArea &area, int &prog_start);

  class COSIFilesException
  {
  public:
    enum Err { E_NONE, E_BAD_FORMAT, E_CHKSUM, E_FORMAT };
  private:
    Err error;
    UINT row;
  public:
    COSIFilesException(Err err= E_NONE, UINT row= 0) : error(err), row(row)
    { }
    /*virtual */~COSIFilesException()
    {}
    /*virtual*/ BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError, PUINT pnHelpContext= NULL);
  };
};


#endif